import axios from 'axios'
const baseUrl = "https://lottery.qnsyw.cn/api/"
// get请求
export function $httpGet(url, params = {}) {
    return new Promise((resolve, reject) => {
        axios.get(baseUrl + url, {
            params: params,
            headers: {
                Authorization: window.localStorage.getItem('token'),
            },
        })
            .then((res) => {
                resolve(res.data);
            })
            .catch((err) => {
                reject(err);
            });
    })
}

// post请求
export function $httpPost(url, data) {
    return new Promise((resolve, reject) => {
        axios.post(baseUrl + url, data, {
            headers: {
                Authorization: window.localStorage.getItem('token') || ''
            },
        }).then(
            (res) => {
                resolve(res.data);
            },
            (err) => {
                reject(err);
            },
        );
    });
}

